<template>
  <div>
    <richTextEditor
      :content="content"
      :isDisabled="isDisabled"
      @changeData="hChangeData"
      @uploadImg="hUploadImg"
      @uploadVideo="hUploadVideo"
    />
  </div>
</template>

<script>
  import richTextEditor from '@/components/commonRichTextEditor'
  export default {
    components: {
      richTextEditor,
    },
    data() {
      return {
        isDisabled: false,
        content: '',
      }
    },
    methods: {
      hChangeData(editDataHtml) {
        // 获取最新的html数据
        this.content = editDataHtml
        console.log(this.content)
      },
      hUploadImg(file, insertFn) {
        console.log('[ file ]', file)
        let imgData = new FormData()
        imgData.append('file', file)
        console.log('[ imgData ]', imgData)
        //调接口，上传图片
        // testUpImg(imgData).then(response => {
        //   if (response.data.code == 0) {
        //     insertFn(response.data.data.url);
        //   } else {
        //   }
        // })
      },
      hUploadVideo(file, insertFn) {
        let videoData = new FormData()
        videoData.append('file', file)
        console.log('[ videoData ]', videoData)
        //调接口，上传视频
        // testUpImg(videoData).then(response => {
        //   if (response.data.code == 0) {
        //     insertFn(response.data.data.url)
        //   } else {
        //   }
        // })
      },
    },
  }
</script>
